﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Snowflake.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common.Framework.Core.Snowflake
{
    public static class SnowflakeConfigure
    {
        /// <summary>
        /// 配置Snowflake
        /// </summary>
        /// <param name="services"></param>
        /// <param name="Configuration"></param>
        /// <returns></returns>
        public static IServiceCollection ConfigureSnowflake(this IServiceCollection services, IConfiguration Configuration)
        {
            services.AddSingleton(item => new IdWorker(1, Configuration.GetValue<int>("ServerNodeNo")));
            return services;
        }
    }
}
